package com.ruoyi.lol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lol.domain.LolHero;
import com.ruoyi.lol.service.ILolHeroService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 英雄字典Controller
 * 
 * @author wyx
 * @date 2025-04-20
 */
@RestController
@RequestMapping("/lol/hero")
public class LolHeroController extends BaseController
{
    @Autowired
    private ILolHeroService lolHeroService;

    /**
     * 查询英雄字典列表
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:list')")
    @GetMapping("/list")
    public TableDataInfo list(LolHero lolHero)
    {
        startPage();
        List<LolHero> list = lolHeroService.selectLolHeroList(lolHero);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('lol:hero:list')")
    @GetMapping("/noPageList")
    public AjaxResult noPageList(LolHero lolHero)
    {
        return AjaxResult.success(lolHeroService.selectLolHeroNoPageList(lolHero));
    }


    /**
     * 查询英雄字典列表
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll()
    {
        return AjaxResult.success(lolHeroService.selectLolHeroList(new LolHero()));
    }
    /**
     * 导出英雄字典列表
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:export')")
    @Log(title = "英雄字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LolHero lolHero)
    {
        List<LolHero> list = lolHeroService.selectLolHeroList(lolHero);
        ExcelUtil<LolHero> util = new ExcelUtil<LolHero>(LolHero.class);
        util.exportExcel(response, list, "英雄字典数据");
    }

    /**
     * 获取英雄字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lolHeroService.selectLolHeroById(id));
    }

    /**
     * 新增英雄字典
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:add')")
    @Log(title = "英雄字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LolHero lolHero)
    {
        return lolHeroService.insertLolHero(lolHero);
    }

    /**
     * 修改英雄字典
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:edit')")
    @Log(title = "英雄字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LolHero lolHero)
    {
        return toAjax(lolHeroService.updateLolHero(lolHero));
    }

    /**
     * 删除英雄字典
     */
    @PreAuthorize("@ss.hasPermi('lol:hero:remove')")
    @Log(title = "英雄字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lolHeroService.deleteLolHeroByIds(ids));
    }
}
